package meijia.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import meijia.bean.UserBean;
import meijia.model.UserInfo;

public class addNewUserServlet extends HttpServlet{
	
	private UserInfo userInfo;
	
	@Override
	 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
	   throws ServletException, IOException {
		doGet(req,resp);
	}
	
	@Override
	 public void doGet(HttpServletRequest req, HttpServletResponse resp)
	   throws ServletException, IOException {
		UserBean userBean = new UserBean();
		userInfo = new UserInfo();
		userInfo.setCardNo(req.getParameter("cardNo"));
		userInfo.setName(req.getParameter("name"));
		userInfo.setPhone(req.getParameter("phone"));
		userInfo.setAddress(req.getParameter("address"));
		userInfo.setNote(req.getParameter("note"));
		userInfo.setMoney(Double.valueOf(req.getParameter("money")));
		userBean.addNewUser(userInfo);
	}

	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}
	
}
